<template>
    <div id="tsdd" >
        <top style="background: #fff;z-index:999;position:fixed;top:0px;color:#444444;height:3rem;font-size:1.1rem;" fixed title="订单详情">
            <div slot="left" @click="goback" style="color:#444444;">
                <!-- <i class="icon njfont nj-goback"></i> -->
                <div class="delivery"  >
                    <i class="symbol1" ></i>
                    <i class="symbol2" ></i>
                </div>
            </div>
            <div slot="right" @click="goKeFu" >
                <i class="icon njfont nj-kefu" style="font-size:1.2rem;border-radius:0.2rem; background: rgb(41, 154, 40);color:#ffffff;"></i>
            </div>
        </top>
        <div class="hzh"  :style="`height: ${screenHeight}px`">
        <vertical-scroll ref='verticalScroll'>
        <div class="order-content">
            <div class="order-goodslist">
                <div class="meal-number">
                    <div v-if="orderDtail.eatingNo" class="meal-number-content">
                        <p class="meal-number-detail">{{orderDtail.eatingNo}}</p>
                        <p class="meal-qch">取餐号</p>
                    </div>
                    <div v-if="orderDtail.orderDetailDTOList && orderDtail.orderDetailDTOList[0].status === 0 && orderDtail.payStatus === 0" class="meal-number-content">
                        <p class="Orderstatus" style="height:100%;line-height:3.5rem;font-size:0.8rem;color:#666666;">待付款</p>
                    </div>
                    <div v-if="orderDtail.orderDetailDTOList && orderDtail.orderDetailDTOList[0].status === 1 && orderDtail.payStatus === 0" class="meal-number-content">
                        <p class="Orderstatus" style="height:100%;line-height:3.5rem;font-size:0.8rem;color:#666666;">已取消</p>
                    </div>
                </div>
                <p v-if="Ris && orderDtail.eatingNo && riStatus" class="meal-notice">
                   <span >请至对应档口取餐&nbsp;{{statusFood}}</span>
                </p>
                <p v-if="!Ris && orderDtail.eatingNo && riStatus" class="meal-notice">
                    <span >已取餐&nbsp;{{statusFood}}</span>
                </p>
                <p v-if="!riStatus && orderDtail.eatingNo" class="meal-notice">
                    <span >已关闭&nbsp;{{statusFood}}</span>
                </p>
                <p v-if="orderDtail.orderDetailDTOList && orderDtail.orderDetailDTOList[0].status === 0 && orderDtail.payStatus === 0 && riStatus" class="meal-notice">
                    <!-- 请在{{getCancelTime}}分钟内进行支付 -->
                    请在{{getCancelTimes(orderDtail.remainingTm)}}分钟内进行支付&nbsp;{{statusFood}}
                </p>
                <p v-if="orderDtail.orderDetailDTOList && orderDtail.orderDetailDTOList[0].status === 1 && orderDtail.payStatus === 0 && riStatus" class="meal-notice">
                    订单已取消&nbsp;{{statusFood}}
                </p>
                <div class="stall-port-list">
                    <div v-for="(i, index) in orderDtail.paraishOrderGoods" :key="index" class="stall-port-item">
                        <div class="port-name" >
                            <span style="height:100%;line-height:1.5rem; display: inline-block;">档口：{{i.stallName}}</span>
                            <span v-if="orderDtail.payStatus == 2 && allGetFood(i.orderGoodsList) && riStatus" style="border:1px solid rgb(239, 84, 35);color:rgb(239, 84, 35);background:#ffffff;margin-left:0.8rem;padding:0.1rem 0.4rem;border-radius: 0.2rem;">当前排队人数：{{i.waitingNum}}</span>
                        </div>
                        <div @click="gotoGoodsDetail(item.goodsCode)" v-for="(item, index) in i.orderGoodsList" :key="index" class="port-food-item">
                            <div style="display: -webkit-box;position: relative;">

                            <div class="food-img">
                                <img class="hzh" v-if="!item.goodsImg" src="static/image/demo2.png" alt="">
                                <img v-else :src="item.goodsImg" alt="" class="zhh">
                                <div v-if="item.buyType==3" class="food-gift">
                                    赠品
                                </div>
                            </div>
                            <div class="food-msg" style="min-height: 5rem;">
                                <div class="food-msg-top">
                                    <span class="food-goodsname">{{item.goodsName}}</span>
                                    <!--<span v-if="item.goodsType != 8 && riStatus" class="food-status" v-html="eatingGoodsStatus(item,orderDtail,index)"></span>-->
                                    <div  class="totalPric">
                                    	<span v-if="item.goodsType != 8 && riStatus" class="food-status" v-html="eatingGoodsStatus(item,orderDtail,index)"></span>
		                                <p style="color:#000000;font-size: 0.6rem;text-align: right;">￥{{getSingerPrices(item)}}</p>
		                                <p style="text-decoration:line-through;color:#6b6b6b;font-size: 0.6rem;text-align: right;" 
		                                v-if="compareMoney(item)==1">￥{{getSingerPrice(item)}}</p>
		                            </div>
                                </div>
                                <div class="food-spec" v-if="item.goodsSpec">
                                    规格：{{item.goodsSpec}}
                                </div>
                                <div class="food-unitPrice">
                                    单价：&#65509;{{Number(item.realPrice).toFixed(2)}}/{{item.mallUnit}}
                                    <!-- <del>¥{{sonPrice(detail)}}</del>{{detail.goodsUnit?'/':''}}&nbsp;{{detail.goodsType == 2 ? detail.mallUnit : (detail.goodsUnit == 'kg' ? '500g' : (detail.mallUnit || ''))}} -->
                                </div>
                                <div class="food-number">
                                    数量：{{item.goodsNum}}{{item.mallUnit}}
                                </div>
                                <div v-if="item.workingInfo" style="text-align:left;color: #999999;height:1rem;">
                                    <span style="float: left;">加工服务：</span><span class="workserve">{{getworkingInfo(JSON.parse(item.workingInfo))}}</span>
                                </div>
                            </div>
                            <!--<div  class="totalPric">
                                <p style="color:#000000;font-size: 0.6rem;">￥{{getSingerPrices(item)}}</p>
                                <p style="text-decoration:line-through;color:#6b6b6b;font-size: 0.6rem;" 
                                v-if="compareMoney(item)==1">￥{{getSingerPrice(item)}}</p>
                            </div>-->
                            </div>
                            <div style="text-align:right;">
                                <div v-if="item.afterSaleStatus!=0" class="handler-btn" @click.stop="getAfterInfor(item)">
                                    查看退款
                                </div>
                                <div v-if="item.eatingStatus === 2 && item.canAfterSaleNum !=0"  :class="item.afterSaleStatus == 0?'handler-btn':'handler-btns'" @click.stop="getAfterSales(item)">
                                    申请退款
                                </div>
                            </div>
                            
                        </div>
                        
                    </div>
                </div>
            </div>
            
        </div>
        <div class="order-price">
            <ul>
                <li>
                    <span>商品合计</span>
                    <span>&#65509;{{orderDtail.orderFee ? Number(orderDtail.orderFee.promTotalPay).toFixed(2) : ''}}</span>
                </li>
                <li>
                    <span>活动优惠</span>
                    <span>-&#65509;{{orderDtail.orderFee ? Number(orderDtail.orderFee.discountCut).toFixed(2) : ''}}</span>
                </li>
                <li>
                    <span>优惠券优惠</span>
                    <span>-&#65509;{{orderDtail.orderFee ? Number(orderDtail.orderFee.ticketCut).toFixed(2) : ''}}</span>
                </li>
            </ul>
            <div class="true-price">
                <span>实付金额</span>
                <span>&#65509;{{Number(orderDtail.realPay).toFixed(2)}}</span>
            </div>
        </div>
        <!-- <div style="background: #ffffff;">
            <span>商品退款详情</span>
            <span>&#65509;{{Number(orderDtail.realPay).toFixed(2)}}</span>
        </div> -->
        <Bill-Order-Detail v-if="orderDtail.orderDetailDTOList && orderDtail.orderDetailDTOList.orderType != 2&&getInvoiceFlag==1" :childOrderList="orderDtail.orderDetailDTOList[0]" :Ris="Ris" :riStatus="riStatus" :showCoupon="showCoupon" :canInvoiceType="canInvoiceType"></Bill-Order-Detail>
        <li id="server_centr" class="aui-list-item" v-if="isShow" @click="goAllAfterSales()">
            <div class="aui-list-item-inner aui-list-item-arrow" style="line-height:2.5rem;height:2.5rem;text-align:left;">
                <div class="aui-list-item-title" >商品退款详情</div>
            </div>
        </li>
        <!-- <div class="receipt-msg">
            <p>
                发票抬头：张笑天
            </p>
            <p>
                身份证号：450881198511085685
            </p>
            <p>
                发票内容：商品明细
            </p>
        </div> -->
        <div class="order-base-msg">
            <!-- <div>
                订单编号：<span id="order-code">{{orderDtail.orderDetailDTOList ? orderDtail.orderDetailDTOList[0].orderNo : ''}}</span>
                <div @click="copyOrderCode" class="copy-btn">复制</div>
            </div> -->
            <div class="aui-list-item-text" style="display: flex;justify-content: space-between;">
                <!--{{item.orderNo}}-->
                <div class="aui-list-item-title" style="line-height:1.5rem;" ref="ordercopy">订单编号：<span id="datas">{{orderDtail.orderDetailDTOList ? orderDtail.orderDetailDTOList[0].orderNo : ''}}</span><span class="aui-font-size-14 text_c_gray"></span></div>
                <div class="aui-list-item-right aui-font-size-14 btns" ref="mycopy" :data-clipboard-text="orderDtail.orderDetailDTOList ? orderDtail.orderDetailDTOList[0].orderNo : ''">
                    <div @click="copyOrderCode" class="aui-btn aui-btn-outlined">复制
                    </div>
                </div>
            </div>
            <p>
                下单时间：{{orderDtail.orderDetailDTOList ? getTime(orderDtail.orderDetailDTOList[0].createTm) : ''}}
            </p>
            <p v-if="orderDtail.orderDetailDTOList && orderDtail.orderDetailDTOList[0].status === 0 && orderDtail.payStatus != 0">
                付款时间：{{orderDtail.orderDetailDTOList ? getTime(orderDtail.orderDetailDTOList[0].payTm) : ''}}
            </p>
        </div>
        <ul v-if="orderDtail.orderFee && orderDtail.orderDetailDTOList[0].status !=1 && orderDtail.orderDetailDTOList[0].payStatus ===2&& orderDtail.orderDetailDTOList[0].payType !=6" class="pay-way">
            <li v-for="(feeItem, index) in orderDtail.orderFee.feeDetails" :key="index" class="pay-way-item">
                <div class="pay-icon">
                    <!-- <i class="icon njfont" :class="iconFunction(feeItem.payType)"></i> -->
                    <img v-if="feeItem.payType == 2 || feeItem.payType == 7 || feeItem.payType == 96 || feeItem.payType == 97" src="static/image/icon_yx.png" style="width: 2rem;height:1.4rem;margin-right: 0.2rem"/>
					<i v-else class="icon njfont" :class="iconFunction(feeItem.payType)" :style="{color:iconStyleFuncion(feeItem.payType)}"></i>
                </div>
                <div class="pay-msg">
                    <div>
                        {{payTypefunction(feeItem.payType)}}
                        <span class="pay-price">
                            &#65509;{{(feeItem.payAmount).toFixed(2)}}
                        </span>
                    </div>
                    <!--<div v-if="orderDtail.orderDetailDTOList && orderDtail.orderDetailDTOList[0].status === 0 && orderDtail.payStatus != 0" >-->
                    <div v-if="orderDtail.orderDetailDTOList  && orderDtail.payStatus != 0" >
						流水号：{{feeItem.serialNumber}}
                    </div>

                </div>
            </li>
        </ul>
        </vertical-scroll>
        </div>
        <Bill-Hint ref="coupon" ></Bill-Hint>
    </div>
</template>
<script>
// &#65509;
import { Toast } from '../../utils/toast'
import { Header } from 'mint-ui';
import goOnlineServer from '@/utils/ZWY/onlineServer';
import axios from 'axios';
import VerticalScroll from '../VerticalScroll';
import { showLoading, hideLoading } from '../../utils/loading.js';
import Clipboard from 'clipboard';
import BillOrderDetail from "../BillOrderDetail";
import { mapMutations, mapActions, mapGetters } from "vuex";
import BillHint from "../BillHint";
export default {
    props: {
        orderDtail: {
            type: Object
        },
        Ris: {//是否全部已取餐状态
            type: Number
        },
        riStatus: {//是否全部是已关闭状态
            type: Number
        },
        statusFood: {
            type: String
        },
        isShow: {
            type: Boolean
        },
    },
    components: {
        top: Header,
        "vertical-scroll": VerticalScroll,
        'Bill-Order-Detail': BillOrderDetail,
        "BillHint": BillHint,
    },
    data() {
        return {
            // ris:null,
            // isShow:null,//判断是否显示查看全部售后信息
            datas:"",//保存全部售后的信息
            childOrderList:[],//保存传入到发票组件的数据
            canInvoiceType:null,
        }
    },
    methods: {
        gotoGoodsDetail(code) {
            this.$router.push({path: 'detailFoods', query: {code: code}})

        },
        payTypefunction(type) {
            let a;
            switch(type) {
                case 1:
                    a = '象谱支付-支付宝支付';
                    break;
                case 2:
                    a = '象谱支付-银行卡支付';
                    break;
                case 3:
                    a = '象谱支付-微信支付';
                    break;
                case 4:
                    a = '象谱支付-工行支付';
                    break;
                case 5:
                    a = '现金支付';
                    break;
                case 6:
                    a = '优惠券支付';
                    break;
                case 7:
                    a = '象谱支付-银联支付';
                    break;
                case 8:
                    a = '象谱支付-威富通';
                    break;
                case 9:
                    a = '钱包余额支付';
                    break;
                case 20:
                    a = '邮费支付';
                    break;
                case 21:
                    a = '积分支付';
                    break;
                case 96:
                    a = '线下银联活动';
                    break;
                case 97:
                    a = '线下银联';
                    break;
                case 98:
                    a = '线下微信';
                    break;
                case 99:
                    a = '线下支付宝';
                    break;						
                default:
                    a = '';
            }
            return a
        },
        iconFunction(type) {
            // console.log("爱奇艺2",type)
            let className;
            switch(type) {
                case 1:
                    className = 'nj-zhifubao';
                    break;
                case 2:
                    className = 'nj-yinlian2';
                    break;
                case 3:
                    className = 'nj-weixin';
                    break;
                case 4:
                    className = 'nj-gonghang';
                    break;
                case 5:
                    className = 'nj-xianjin';
                    break;
                case 6:
                    className = 'nj-youhuiquan1';
                    break;
                case 7:
                    className = 'nj-yinlian1';
                    break;
                case 8:
                    className = 'nj-weifutong';
                    break;
                case 9:
                    className = 'nj-qianbao';
                    break;
                case 21:
                    className = 'nj-jifen2';
                    break;	
                case 96:
                    className = 'nj-yinlian1';
                    break;
                case 97:
                    className = 'nj-yinlian1';
                    break;
                case 98:
                    className = 'nj-weixin';
                    break;
                case 99:
                    className = 'nj-zhifubao';		
                    break;
                default:
                    className = '';			
            }
            return className
        },
        iconStyleFuncion(type) {
				let colorType;
				switch(type) {
					case 1:
						colorType = '#00a8ee';
						break;
					case 2:
						colorType = '#185ba7';
						break;
					case 3:
						colorType = '#05af10';
						break;
					case 4:
						colorType = '#c00925';
						break;
					case 5:
						colorType = '#ed3f3f';
						break;
					case 6:
						colorType = '#f44336';
						break;
					case 7:
						colorType = '#2196f3';
						break;
					case 8:
						colorType = '#1976d2';
						break;
					case 9:
						colorType = '#ff9100';
						break;
					case 21:
						colorType = '#ffd156';
						break;
					case 96:
						colorType = '#2196f3';
						break;
					case 97:
						colorType = '#2196f3';
						break;
					case 98:
						colorType = '#05af10';
						break;
					case 99:
						colorType = '#00a8ee';
						break;		
					default:
						colorType = '';
				}
				return colorType
			},
        goback() {
            // this.$router.back()
            let num = this.$route.query.orderStatus;
            if(num == -1) {
                window.history.go(-1);
            } else {
                this.$router.replace({
                    path: 'order',
                    query: {
                        orderStatus: num
                    }
                })
            }

        },
        ismobile(test) {
            var u = navigator.userAgent,
                app = navigator.appVersion;
            if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))) {
                if(window.location.href.indexOf("?mobile") < 0) {
                    try {
                        if(/iPhone|mac|iPod|iPad/i.test(navigator.userAgent)) {
                            return '0';
                        } else {
                            return '1';
                        }
                    } catch(e) {}
                }
            } else if(u.indexOf('iPad') > -1) {
                return '0';
            } else {
                return '1';
            }
        },
        copyOrderCode() {
            // var Url2=document.getElementById("order-code").innerText;
            // var oInput = document.createElement('input');
            // oInput.value = Url2;
            // document.body.appendChild(oInput);
            // oInput.select(); // 选择对象
            // document.execCommand("Copy"); // 执行浏览器复制命令
            // oInput.className = 'oInput';
            // oInput.style.display='none';
            // Toast({
            //     message: "复制成功"
            // })
            let num = this.ismobile(1);
            if(num == '0') {
                if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) { //ios
                    var copyDOM = document.querySelector('#datas'); //要复制文字的节点
                    var range = document.createRange();
                    // 选中需要复制的节点
                    range.selectNode(copyDOM);
                    // 执行选中元素
                    window.getSelection().addRange(range);
                    // 执行 copy 操作
                    var successful = document.execCommand('copy');
                    try {
                        var msg = successful ? 'successful' : 'unsuccessful';
                    } catch(err) {}
                    if(msg) {
                        Toast({
                            message: '复制成功',
                            // iconClass: "aui-iconfont aui-icon-correct",
                            duration: 2000,
                            type: 'success'
                        });
                    }
                    // 移除选中的元素
                    window.getSelection().removeAllRanges();
                }
            }

        },
        getworkingInfo(val) {
			if(val instanceof Array) {
				return val[0].processingItem
			} else {
				return val.processingattribute
			}
		},
        getRef() {
            let num = this.ismobile(1);
            if(true) {
                const clipboard = new Clipboard('.btns');
                if(Clipboard.isSupported()) {
                    clipboard.on('success', function(e) {
                        Toast({
                            message: '复制成功',
                            // iconClass: "aui-iconfont aui-icon-correct",
                            duration: 1000,
                            type: 'success'
                        });
                        clipboard.destroy();
                    });
                    clipboard.on('error', function(e) {
                        Toast({
                            message: '复制失败',
                            // iconClass: "aui-iconfont aui-icon-close",
                            duration: 1000,
                            type: 'fail'
                        });
                    });
                }

            }
        },
        eatingGoodsStatus(item,val,index) {
            // console.log(val,"查看传入的值-------------------------------------------")
            const status = item.eatingStatus
            if (item.payStatus === 0) {
                return "<span style='color:#666666'>待付款</span>"
            }
            // if (val&&val.orderDetailDTOList[0].status === 2) {
            //     return "<span style='color:#666666'>已关闭</span>"
            // }
            switch (status) {
                case 0:
                    return "<span style='color:rgb(41, 154, 40)'>制作中</span>"
                    break;
                case 1:
                    return "<span style='color:rgb(239, 84, 35)'>待取餐</span>"
                    break;
                case 2:
                    return "<span style='color:#666666'>已取餐</span>"
                default:
                    break;
            }
        },
                //转换时间格式
        getTime(param, type) {
            if(!param) {
                return
            }
            let date = new Date(param);
            let year = date.getFullYear();
            let month = checkTime(date.getMonth() + 1);
            let day = checkTime(date.getDate());
            let hour = checkTime(date.getHours());
            let min = checkTime(date.getMinutes());
            let sec = checkTime(date.getSeconds());

            function checkTime(i) {
                if(i < 10) {
                    i = '0' + i;
                }
                return i;
            }

            if(type === 1) {
                return day + '天' + hour + '小时' + min + '分';
            }

            return year + '-' + month + '-' + day + ' ' + hour + ':' + min;
        },
        goKeFu(){
            goOnlineServer(this);
        },
        //判断是否全部已取餐//eatingStatus==2 已取餐    ==3 缺货
        allGetFood(list){
            console.log(list,"///////////////////**")
            let ris = false;
            list && list.forEach(element => {
                if( element.eatingStatus != 2 &&  element.eatingStatus != 3){
                    ris = true;
                }
               
            });
            return ris;
        },
        // //判断是否全部已取餐2
        // async allGetFoodsly(list){
        //     console.log(list,"///////////////////**123")
        //     this.ris = 0;
        //     list.forEach(elements => {
        //         let item = elements.orderGoodsList;
        //         item.forEach(element =>{
        //             if( element.eatingStatus != 2){
        //                 this.ris = 1;
        //                 console.log(this.ris,"sanfjnaskfnkasnf-2内循环2------")
        //                 return this.ris;
        //             }
        //         })
                
               
        //     });
        //     console.log(this.ris,"sanfjnaskfnkasnf-外循环2------")
        //     return this.ris;
        // },
         // 根据商品查售后信息
        getAfterInfor(item){
            // console.log("window.api.service_host",window.api)
            // console.log("window.localStorage.sessionId",window.localStorage.sessionId)
            let orderNo = item.orderNo;
            let orderGoodsId = item.rid;
            let sessionId =  window.localStorage.sessionId;
            // this.orderDtail.orderTicketList[index].orderNo
            let config = {
                url:window.api.service_host+"/afterSales/selectAfterSalesByGoods/"+ orderNo+"/"+ orderGoodsId,
                method: 'GET',
                // params,
                headers: {'sessionId': sessionId},
            };
            axios(config).then((res) => {
                console.log("根据商品查售后信息000000000",res)
                try {
                    if(res.data.returnCode === 1){
                        let data = res.data.data;
                        if(data[0].serviceStatus == 12){
                            this.$router.push({path: 'AfterSalesInfo', query: {data: data,isAll:false}})
                        }else{
                             Toast({
                                message: '退款未成功',
                                duration: 1000,
                                type: 'fail'
                            })
                        }
                        
                    }
                } catch (error) {
                    console.log("error",error)
                }
            })

        },
         // 查全部的售后信息
        // async getAllAfterInfor(){
        //     console.log("查全部的售后信息556677-----",)
        //     let sessionId =  window.localStorage.sessionId;
        //     let orderNo = await this.orderDtail.paraishOrderGoods?this.orderDtail.paraishOrderGoods[0].orderGoodsList[0].orderNo:"";
        //     let data ={
        //         orderNo:orderNo,
        //         serviceStatus:12
        //     } 
        //     let config = {
        //         url:window.api.service_host+"/afterSales/selectAfterSalesList/",
        //         method: 'GET',
        //         // params:JSON.stringify(data),
        //         params:data,
        //         headers: {'sessionId': sessionId},
        //     };
        //     // showLoading();
        //     await axios(config).then((res) => {
        //         console.log("查全部的售后信息",res)
        //         try {
        //             if(res.data.returnCode === 1){
        //                 // hideLoading();
        //                 if(res.data.data.length){
        //                     this.isShow= true;
                            
        //                 }else{
        //                     this.isShow= false;
        //                     return
        //                 }
        //             }
        //         } catch (error) {
        //             this.isShow= false;
        //             // hideLoading();
        //         }
        //     })

        // },
        //跳转查看全部退款页面
        async goAllAfterSales(){
            let sessionId =  window.localStorage.sessionId;
            let orderNo = await  this.orderDtail.paraishOrderGoods?this.orderDtail.paraishOrderGoods[0].orderGoodsList[0].orderNo:'';
            let data ={
                orderNo:orderNo,
                serviceStatus:12
            } 
            let config = {
                url:window.api.service_host+"/afterSales/selectAfterSalesList/",
                method: 'GET',
                // params:JSON.stringify(data),
                params:data,
                headers: {'sessionId': sessionId},
            };
            showLoading();
            await axios(config).then((res) => {
                console.log("查全部的售后信息",res)
                try {
                    if(res.data.returnCode === 1){
                        hideLoading();
                        if(res.data.data.length){
                            let datas = res.data.data;
                            this.$router.push({path: 'AfterSalesInfo', query: {data: datas,isAll:true}})
                        }else{
                            Toast({
                                message: res.msg || '查询售后单无数据！',
                                duration: 1000,
                                type: 'success'
                            })
                            return
                        }
                    }
                } catch (error) {
                    console.log("error",error)
                    Toast({
                        message: res.msg || '数据加载异常！',
                        duration: 1000,
                        type: 'fail'
                    })
                    hideLoading();
                }
            })
        },
        //跳转申请退款页面
        getAfterSales(item){
               console.log(item,"item123131646546897979794646466131313")
            this.$router.push({path: 'afterSale', query: {orderNo: item.orderNo,goodsCode:item.goodsCode,buyType:item.buyType,tangShi:"1",rid:item.rid}})
            // query:{orderNo:detail.orderNo,goodsCode:detail.goodsCode,buyType:detail.buyType}
        },
        getCancelTimes(val) {
            let s = val / 1000;
            let min  = s / 60;
            if(min > parseInt(min)){
                min = parseInt(min) + 1;
            }else{
                min = parseInt(min)
            }
            return min;
        },
        getBillStatus(){
            //获取发票使用状态
            var sessionId = localStorage.getItem('sessionId');
            var config = {
                url : window.api.base_host+'/baseConfig/findByCode',
            //    data:JSON.stringify(datas),
                method:"GET",
                headers: {'sessionId': sessionId, 'Content-Type':'application/json', 'Accept' : 'application/json'},
            }
            axios(config).then((res) => {
                try{
                    if(res.data.returnCode === 1){
                        this.setInvoiceFlag(res.data.data[0].invoiceFlag)

                    }else {
                    
                    }
                }catch(err){

                }
                
            })
        },
        getSingerPrice(item){//原价小计金额
            // if(item.buyType == 1){
                var str = '';
                if(item.mallUnit){
                    // str = Number(item.promTotalMoney ).toFixed(2);
                    str = Number(item.totalMoney).toFixed(2);
                }else{
                    // str = Number(item.promTotalMoney ).toFixed(2)
                    str = Number(item.totalMoney).toFixed(2)
                }
                return str || '';
            // }else{
            //     let str = Number(item.totalMoney).toFixed(2);
            //     return str || '';
            // }
        },
        getSingerPrices(item){//优惠后的总金额
            // if(item.buyType == 1){
                var str = '';
                if(item.mallUnit){
                    str = Number(item.realTotalMoney).toFixed(2);
                }else{
                    str = Number(item.realTotalMoney).toFixed(2)
                }
                return str || '';
            // }else{
            //     let str = Number(item.realTotalMoney ).toFixed(2);
            //     return str || '';
            // }
        },
        //比较价格
        compareMoney(item){
            let a = 0;
            // console.log("12345678910--***********************",this.getSingerPrices(item),this.getSingerPrice(item),)
            if(this.getSingerPrice(item) - this.getSingerPrices(item) > 0){
                a = 1//原价大于优惠的情况
                return a;
            }else if(this.getSingerPrice(item) - this.getSingerPrices(item) == 0){
                a = 2;//相等的情况，未参加活动
                return a;
            }
            return a;
        },
        getOderId() {
            // console.log("123456")
            // this.orderID = this.$route.query.shopId;
            this.getOrderBillDetail(this.$route.query.shopId);
        },
        //根据shopId来获取发票详情
        getOrderBillDetail(val){
            this.$store.dispatch('hzh/GetOrderBills',val)
        },
        // sonPrice(son) {
        //     let a = son.mallUnit == 'kg' ? Number(son.goodsPrice / 2).toFixed(2) : Number(son.totalMoney / son.outGoodsNum).toFixed(2);
        //     return a;
        // },
       showCoupon() {
			console.log("xxxxx")
            this.$refs.coupon.showCover()
		},
    },
    computed: {
        getCancelTime() {
            if (!this.orderDtail.orderDetailDTOList) {
                return ''
            }
            let mss;
            if(this.orderDtail.orderDetailDTOList[0].autoCancelTm) {
                mss = this.orderDtail.orderDetailDTOList[0].autoCancelTm - new Date().getTime();
                let days = parseInt(mss / (1000 * 60 * 60 * 24));
                let hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                let minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60));
                return(days > 0 ? (days + " 天 ") : '') + (hours > 0 ? (hours + " 小时 ") : '') + minutes;
            } else {
                mss = 30
            }
            if(mss < 0) {
                return 0;
            }
            return mss;
        },
        screenHeight() {
            return window.innerHeight;
        },
        ...mapGetters('zwy', [
            'getInvoiceFlag',
        ]),
    },
    watch: {
        orderDtail() {
            setTimeout(() => {
                this.getRef();
            }, 20);
        }
    },
    async created() {
        // await this.getAllAfterInfor();
        // await this.allGetFoodsly(this.orderDtail.paraishOrderGoods)
        // console.log(this.Ris,"this.Risthis.Risthis.Risthis.Ris")
        await this.getOderId();
        console.log("this.getInvoiceFlag线上",this.getInvoiceFlag)
        if(this.getInvoiceFlag==null){
            this.getBillStatus();
        }
        //查看是否可以开票
		this.canInvoiceType = this.$route.query.canInvoiceType;
    },
    mounted(){
        
        // this.orderDetailDTOList = this.orderDtail.orderDetailDTOList;
//         console.log(this.orderDtail,"qwer9999999999999999999",this.orderDetailDTOList)
    },
    updated() {
        this.$nextTick(() => {
            setTimeout(()=>{
                this.$refs.verticalScroll && this.$refs.verticalScroll.refresh();
            },500)
        });
    },
    
}
</script>
<style scoped>
    .pay-way-item {
        background: #ffffff;
        margin-top: 0.5rem;
        overflow: hidden;
        padding: 0 0.5rem;
        height: 3rem;
        display: flex;
    }

    .pay-icon {
       
        height: 100%;
        padding-top: 0.6rem;
        padding-right: 0.5rem;
    }
    .pay-icon i {
        font-size: 1.8rem;
    }
    .pay-icon .nj-qianbao {
        color: rgb(239, 84, 35);
    }
    .pay-msg {
        flex: 1;
        text-align: left;
        padding-top: 0.5rem;
        line-height: initial;
        color: #666666;
    }
    .pay-price {
        float: right;
        color: #1e1e1e;
    }
    .copy-btn {
        float: right;
        padding: 0 0.6rem;
        border: 1px solid #ededed;
        font-size: 0.6rem;
        border-radius: 0.2rem;
        color: #999999;
    }
    .receipt-msg,.order-base-msg {
        margin-top: 0.5rem;
        background: #ffffff;
        text-align: left;
        padding: 0.4rem 0.5rem ;
        
    }
    .receipt-msg p,.order-base-msg p {
        /* height: 1.2rem;
        line-height: 1.2rem; */
        color: #666666;
    }
    .true-price {
        height: 2rem;
        line-height: 2rem;
        padding: 0 0.5rem;
        font-size: 0.75rem;
    }
    .true-price span:first-child {
        float: left;
        color: #333333;
        font-weight: 700;
    }
    .true-price span:last-child {
        float: right;
        color: rgb(239, 84, 35);
        font-size: 0.9rem;
    }
    .order-price {
        background: #ffffff;

    }
    .order-price ul {
        padding: 0.2rem 0 0.4rem;
        border-bottom: 1px solid #ededed;
    }
    .order-price ul li {
        width: 100%;
        overflow: hidden;
        padding: 0 0.5rem;
        /* height: 1.2rem;
        line-height: 1.2rem; */
    }
    .order-price ul li span:first-child {
        float: left;
        color: #6b6b6b;
    }
    .order-price ul li span:last-child {
        float: right;
        color: #1e1e1e;
    }
    .handler-btn {
        /* position: absolute; */
        /* right: 0; */
        /* bottom: 0.5rem; */
        width: 3.5rem;
        height:1.1rem;
        /* float: right; */
        padding: 0 0.3rem;
        border: 1px solid #dddddd;
        color: #999999;
        border-radius: 0.2rem;
        margin-left: 0.3rem;
        display:inline-block;
    }
    .totalPric {
		float: right;
        /*position: absolute;
        right: 0rem;
        bottom: 1.8rem;*/
        /*padding: 0 0.3rem;*/
        /* border: 1px solid #dddddd; */
        color: #999999;
        border-radius: 0.2rem;
    }
    .handler-btns {
        position: absolute;
        right: 4rem;
        bottom: 0.5rem;
        padding: 0 0.3rem;
        border: 1px solid #dddddd;
        color: #999999;
        border-radius: 0.2rem;
    }
    .food-spec, .food-unitPrice, .food-number {
        text-align: left;
        color: #999999;
    }
    .food-status {
        font-size: 0.7rem;
        /*float: right;*/
        /* display: inline-block; */
    }
    .food-msg-top {
        color: #333333;
        text-align: left;
        font-size: 0.7rem;
        padding-bottom: 0.3rem;
        max-height:2.4rem ;
         min-height: 2.3rem;
    }
    .food-goodsname{
        float: left;
        max-height: 2.3rem;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        width: 75%;
        display: -webkit-box;
    }
    .port-food-item {
        margin: 0.5rem;
        overflow: hidden;
        border-bottom: 1px solid #ededed;
        padding-bottom: 0.5rem;
        /* display: flex; */
        position: relative;
    }
    .food-gift {
        position: absolute;
        width: 100%;
        height: 1rem;
        bottom: 0;
        left: 0;
        text-align: left;
        color: #ffffff;
        background: rgb(239, 84, 35);
        font-size: 0.6rem;
        line-height: 1rem;
        padding-left: 0.2rem;
    }
    .food-img {
        float: left;
        width: 4.05rem;
        height: 4.05rem;
        position: relative;
    }
    .food-img img {
        width: 100%;
        height: 100%;
    }
    .food-msg {
        flex: 1;
        font-size: 0.6rem;
        margin-left: 0.5rem;
    }
    .port-name {
        text-align: left;
        margin: 1rem 0.5rem 0.5rem;
        color: #333333;
        background: #ededed;
        padding: 0rem 0.4rem;
        font-size: 0.6rem;
        border: 1px solid #dddddd;
        height: 1.5rem;
        line-height: 1.5rem;
    }
    .meal-notice {
        padding-top: 3.5rem;
        font-size: 0.8rem;
        color: #333333;
        font-weight: 800;
    }
    .meal-qch {
        line-height: inherit;
        font-size: 0.6rem;
    }
    .meal-number-detail {
        font-size: 1rem;
        font-weight: 700;
        color: #333333;
        line-height: inherit;
        margin-top: 0.65rem;
    }
    .meal-number-content {
        position: absolute;
        width: 4.2rem;
        height: 4.2rem;
        background: white;
        border-radius: 2.1rem;
        left: 50%;
        top: 50%;
        transform: translate(-50%,-50%);
        border: 0.2rem solid rgb(41, 154, 40);
        text-align: center;
    }
    .order-goodslist {
        margin: 2rem 0.5rem 0;
        background: white;
        position: relative;
        border-radius: 0.4rem;
        
    }
    .meal-number {
        background: #ffffff;
        width: 4.6rem;
        height: 4.6rem;
        border-radius: 2.3rem;
        position: absolute;
        top: -1.7rem;
        left: 50%;
        transform: translate(-50%,0)
    }
    .order-content {
        /* background: rgb(41, 154, 40); */
        width: 100%;
        padding-bottom: 0.01rem;
        padding-top: 3rem;
    }
    .delivery {
        padding: 0.4rem 1rem 0.4rem 0.6rem;
        cursor: pointer;
        margin-left: 0.4rem;
        margin-top: -2px;
        position: absolute;
        top: 0.5rem;
        left: 0;
        will-change: transform;
        transition: all .2s ease-out 0.1s;
    }
    #tsdd .aui-title {
        text-align: center !important;
    }
    .my-header {
        background: rgb(41, 154, 40) !important;
        color: white;
        border: none;
    }
    .hzh{
		flex: 1;
		/* overflow-y: auto; */
        position: relative;
        top:-1px;
        /* overflow-x: hidden; */
        overflow: hidden;
        background: #eaeaea;
    }
    #server_centr{
        position: relative;
        background: #ffffff;
        padding-left:0.5rem;
        margin-top: 0.5rem;
        /* border-top:1px solid #dddddd; */
    }
    .workserve{
        float: left;
        width: 45%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
</style>

